<template>
	<view class="addresslistmian">
		<view
			class="list"
			:class="item.is_default == 1 ? 'active' : ''"
			v-for="(item, i) in addressdata"
			@tap="Tapindex(i)"
		>
			<view>
				<text>收货人:</text>
				<text>{{ item.name }}</text>
			</view>
			<view>
				<text>手机号:</text>
				<text>{{ item.phone }}</text>
			</view>
			<view>
				<text>所在地区:</text>
				<text>
					{{ item.province }}{{ item.city }}{{ item.county }}
				</text>
			</view>
			<view>
				<text>详细地址:</text>
				<text>{{ item.address }}</text>
			</view>
			<view>
				<text
					class="iconfont icon-shanchu"
					@tap.stop="deleteress(item.id)"
				></text>
			</view>
		</view>
	</view>
</template>

<script setup>
const emit = defineEmits(['upaddress', 'emitdelete']);
const props = defineProps({
	addressdata: {
		type: Array,
		default() {
			return [];
		}
	}
});
const Tapindex = i => {
	console.log(i);
	emit('upaddress', i);
};
const deleteress = id => {
	console.log(id);
	emit('emitdelete', id);
};
</script>

<style lang="scss">
.addresslistmian {
	// position: relative;
	.list {
		margin-top: 10px;
		border: 1px solid;
		border-radius: 10px;
		padding: 10px;
		view {
			height: 30px;
			line-height: 30px;
		}
	}
	.iconfont {
		position: absolute;
		display: flex;
		right: 10px;
	}
	.active {
		border-color: red;
	}
}
</style>
